// 引入mockjs

const Mock = require('mockjs');

// 获取 mock.Random 对象

const Random = Mock.Random;

// mock一组数据

const produceNewsData = function() {

    let articles = [];

    //订单页数据
    let allOrders = [];

    for (let i=0; i<100; i++) {
        let newAllOrderObjectOne = {
            name: Random.cname(),
            id: Random.id(), // 身份证号
            age: Random.integer(20, 50),
            address: Random.county(true),
            email: Random.email("qq.com")
        }
        let newAllOrderObjectTwo = Mock.mock({
            'num|+1': 1,
            'number': /[D][E][M][A][1][0-9][0-9][0-9][0-9][0-9][0-9]/,
            'pay': /[1-9][0-9][0-9][0-9]/,
            'creationTime': '2021年1月25日',
            'expiryTime': '2021年1月26日',
            'orderState|1': [
                "未支付",
                "待运输",
                "运输中",
                "已签收",
                "退款中"
            ]
        })
        let newAllOrderObject = Object.assign(newAllOrderObjectOne,newAllOrderObjectTwo);
        allOrders.push(newAllOrderObject)
    }


    for (let i = 0; i < 100; i++) {

        let newArticleObject = {
            //title: Random.csentence(5, 30), //  Random.csentence( min, max )
            name: Random.cname(), // Random.cname() 随机生成一个常见的中文姓名
            nickname: Random.last(),
            id: Random.id(),
            role: Random.pick(['Develop', 'Test', 'PM', 'Designer']),
            describe: Random.csentence(5, 15)
        }

        articles.push(newArticleObject)

    }



    return {


        articles: articles,

        allOrders:allOrders


    }

}



// Mock.mock( url, post/get , 返回的数据)；

Mock.mock('/news/index', 'post', produceNewsData);

